package backtracking;

import java.util.ArrayList;
import java.util.List;
import java.util.Stack;

public class LeetCode_77 {
    public static void main(String[] args) {
        combine(10, 4);
        for (List<Integer> integers : result) {
            System.out.println(integers);
        }
    }
    static List<List<Integer>> result = new ArrayList<>();
    static Stack<Integer> r = new Stack<>();
    public static void combine(int n, int k) {
        back(1,n,k);
    }
    public static void back(int b,int n, int k){
        if(r.size() == k){
            result.add(new ArrayList<>(r));
            return;
        }
        for (int i = b; i <= n; i++) {
            r.push(i);
            back(i + 1,n,k);
            r.pop();
        }
    }
}
